package com.clstu.enum_.enumeration_;

public class Enumeration01 {
    public static void main(String[] args) {
//        Season temp;
//        temp=Season.AUTUMN;
//        Season.AUTUMN=Season.SPRING;//交换季节
//        Season.SPRING=temp;


        System.out.println(Season.AUTUMN);
        System.out.println(Season.SPRING);
        System.out.println(Season.WINTER);
        System.out.println(Season.SUMMER);
    }
}
class Season{//1.构造器私有化，2.所有的setter去掉 3.自行构建 public static final 类型的所有对象 4.这样一来就只有枚举过的对象，不会产生新的对象
    private String name;
    private String desc;
    public static final Season SPRING = new  Season("春季", "温暖");//定义成final就可以防止恶意的交换两个季节
    public static final Season SUMMER = new  Season("夏季", "炎热");
    public static final Season AUTUMN = new  Season("秋季", "凉爽");
    public static final Season WINTER = new  Season("冬季", "寒冷");
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}